package com.bwie.controller;

import com.bwie.pojo.TbOrder;
import com.bwie.pojo.TbProdInfo;
import com.bwie.service.TbOrderService;
import com.bwie.utils.Result;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/shop/order")
public class TbOrderController {
    @Autowired
    TbOrderService tbOrderService;

    @PostMapping("/addOrder")
    public Result addOrder(@RequestBody List<TbProdInfo> prodInfoList){
        return tbOrderService.addOrder(prodInfoList);
    }

    @PostMapping("/getOrderList")
    public Result getOrderList(@RequestBody PageInfoVo pageInfoVo){
        return tbOrderService.getOrderList(pageInfoVo);
    }

    /**
     * 批量删除订单
     * @param tbOrderList
     * @return
     */
    @PostMapping("/deleteAll")
    public Result deleteAll(@RequestBody List<TbOrder> tbOrderList){
        return tbOrderService.deleteAll(tbOrderList);
    }

    /**
     * 导出订单表格
     * @param ids
     */
    @GetMapping("/exportExcel/{ids}")
    public void exportExcel(@PathVariable("ids") String ids){
        tbOrderService.exportExcel(ids);

    }
}
